<?php $this->load->view('wap/head.php'); ?>
    <div class="fixed-group" style="display: none;">
        <div class="top-btn"><span class="iconfont icon-zhiding"></span></div>
    </div>
    <!-- 模拟变量 -->
    <input type="hidden" name="title" id="title" value="17koko游戏"/>

    <!-- owl.carousel-->
    <link rel="stylesheet" href="<?php echo base_url(); ?>default/wap/css/owl.carousel.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>default/wap/css/owl.theme.css">
    <script src="<?php echo base_url(); ?>default/wap/js/owl.carousel.min.js"></script>
    <script src="<?php echo base_url(); ?>default/wap/js/index.js?v=3"></script>

    <style type="text/css">
        body {
            background-color: #f0f0e1;
        }

    </style>

    <div class="pages center-block pages-index">

        <div class="hd-head">
            <img class="logo" src="<?php echo base_url(); ?>default/wap/img/logo.png">
            <div class="mb-logo">
                <div class="citys">

                    <div class="btn-group">
                        <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown"
                                aria-expanded="false">
                            <div class="cityid">
                                <?php foreach ($city as $key => $val) {
                                    if ($cityid == $val['id']) {
                                        echo $val['area_name'];
                                    }
                                } ?>
                            </div>
                            <span class="caret2"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <?php foreach ($city as $key => $val) { ?>
                                <li>
                                    <a href="#"
                                       data-type="<?php echo $val['id']; ?>"><?php echo $val['area_name']; ?></a>
                                </li>
                            <?php } ?>
                        </ul>
                    </div>
                </div>


                <div class="search-box">
                    <input class="search-inp" type="text" id="search" name="search" placeholder="搜索"/>
                    <div class="icon-search"></div>
                </div>
            </div>
            <script>
                $(function () {
                    <?php if($type == 0){ ?>
                    $("#ul-hots").trigger("click");
                    <?php }elseif($type == 1){ ?>
                    $("#ul-prize").trigger("click");
                    <?php }elseif($type == 2){ ?>
                    $("#ul-recommend").trigger("click");
                    <?php } ?>
                });
            </script>
            <ul class="navs">
                <li>
                    <a id="ul-prize" data-add="ul-prize" class="city" href="#nav-prize">最新</a>
                </li>
                <li>
                    <a id="ul-hots" data-add="ul-hots" class="" href="#nav-hots">热门</a>
                </li>
                <li>
                    <a id="ul-recommend" data-add="ul-recommend" class="a-recommend" href="#nav-recommend">最近玩过</a>
                </li>
                <!-- 隐藏未上线栏目 start-->
                <!--
                <li>
                <a data-add="ul-libao" class="a-libao" href="#nav-libao">礼包</a>
                </li>
                <li>
                <a class="a-dingzhi" href="#nav-dingzhi">定制</a>
                </li>
                -->
                <!-- 隐藏未上线栏目 end-->
            </ul>
        </div>
        <!-- ./hd-head -->

        <!-- Tab panes -->
        <div class="tab-content">
            <!-- 最新游戏 -->
            <div role="tabpanel" class="tab-pane" id="nav-prize">

                <?php if ($advert) { ?>
                    <div class="owl-out">
                        <div class="owl-b">
                            <div class="owl-carousel owl-index">
                                <?php foreach ($advert as $key => $val) {
                                    if ($val['status'] == 1) { ?>
                                        <div>
                                            <a href="<?php echo $val['url'] . '?channel=nbanner'; ?>">
                                                <img src="<?php echo base_url($val['picture']); ?>"/>
                                            </a>
                                        </div>
                                    <?php }
                                } ?>
                            </div>
                        </div>
                    </div>
                <?php } ?>

                <div class="adv-hot">
                    <div class="bd-adv">
                        <img class="adv-hot-logo" src="<?php echo base_url(); ?>default/wap/img/logo.png">
                        <div class="adv-hot-r">
                            <button type="button" class="btn btn-follow" data-toggle="modal" data-target="#gh_qrcode">关注</button>
                            <div class="adv-hot-r-l">
                                关注我们
                                <br>即时了解最新资讯
                            </div>
                        </div>
                    </div>

                </div>

                <div class="bd-hots">
                    <div class="ul-prize-pre" style="display: none">
                        <li>
                            <img class="thumb" src="#"/>
                            <div class="info">

                                <div class="info-right">
                                    <p>
                                        <span class="popularity-txt">人气：</span>
                                        <span class="popularity">1717</span>
                                    </p>
                                    <p>
                                        <a href="#" class="btn btn-play">开始游戏</a>
                                    </p>
                                </div>

                                <div class="info-left">
                                    <p class="hd">我就MT</p>
                                    <p>
                                        <span class="tag tag-new">new</span>
                                        <span class="tag tag-hot">hot</span>
                                    </p>
                                    <p class="desc">一款神马游戏</p>
                                </div>

                            </div>

                        </li>
                    </div>
                    <ul class="ul-prize">
                        <?php foreach ($prize as $key => $val) { ?>

                            <li>
                                <img class="thumb" src="<?php if ($val['picture']) {
                                    echo base_url() . $val['picture'];
                                } else {
                                    echo base_url() . 'default/wap/img/g2.jpg';
                                } ?>"/>
                                <div class="info">
                                    <div class="info-right">
                                        <p>
                                            <span class="popularity-txt">人气：</span>
                                            <span class="popularity"><?php echo $val['click']; ?></span>
                                        </p>
                                        <p>
                                            <a href="javascript:click_ajax(<?php echo $val['id']; ?>,'<?php echo base_url("index.php/wap/index/togame/{$val['id']}").'?channel=new'; ?>');"
                                               class="btn btn-play">开始游戏</a>
                                        </p>
                                    </div>
                                    <div class="info-left">
                                        <p class="hd"><?php echo $val['title']; ?></p>
                                        <p>
                                            <span class="tag tag-new">new</span>
                                        </p>
                                        <p class="desc"><?php echo $val['description']; ?></p>
                                    </div>
                                </div>
                            </li>
                        <?php } ?>
                    </ul>
                </div>
            </div>
            <!-- 热门游戏 -->
            <div role="tabpanel" class="tab-pane" id="nav-hots">

                <?php if ($advert) { ?>
                    <div class="owl-out">
                        <div class="owl-b">
                            <div class="owl-carousel owl-index">
                                <?php foreach ($advert as $key => $val) {
                                    if ($val['status'] == 2) { ?>
                                        <div>
                                            <a href="<?php echo $val['url'] . '?channel=hbanner'; ?>">
                                                <img src="<?php echo base_url($val['picture']); ?>"/>
                                            </a>
                                        </div>
                                    <?php }
                                } ?>
                            </div>
                        </div>
                    </div>
                <?php } ?>

                <div class="adv-hot">
                    <div class="bd-adv">
                        <img class="adv-hot-logo" src="<?php echo base_url(); ?>default/wap/img/logo.png">
                        <div class="adv-hot-r">
                            <button type="button" class="btn btn-follow" data-toggle="modal" data-target="#gh_qrcode">关注</button>
                            <div class="adv-hot-r-l">
                                关注我们
                                <br>即时了解最新资讯
                            </div>
                        </div>
                    </div>

                </div>

                <div class="bd-hots">
                    <div class="ul-hots-pre" style="display: none">
                        <li>
                            <img class="thumb" src="#"/>
                            <div class="info">

                                <div class="info-right">
                                    <p>
                                        <span class="popularity-txt">人气：</span>
                                        <span class="popularity">1717</span>
                                    </p>
                                    <p>
                                        <a href="#" class="btn btn-play">开始游戏</a>
                                    </p>
                                </div>

                                <div class="info-left">
                                    <p class="hd">我就MT</p>
                                    <p>
                                        <span class="tag tag-new">new</span>
                                        <span class="tag tag-hot">hot</span>
                                    </p>
                                    <p class="desc">一款神马游戏</p>
                                </div>

                            </div>

                        </li>
                    </div>
                    <ul class="ul-hots">
                        <?php foreach ($hot as $key => $val) { ?>

                            <li>
                                <img class="thumb" src="<?php if ($val['picture']) {
                                    echo base_url() . $val['picture'];
                                } else {
                                    echo base_url() . 'default/wap/img/g2.jpg';
                                } ?>"/>
                                <div class="info">
                                    <div class="info-right">
                                        <p>
                                            <span class="popularity-txt">人气：</span>
                                            <span class="popularity"><?php echo $val['click']; ?></span>
                                        </p>
                                        <p>
                                            <a href="javascript:click_ajax(<?php echo $val['id']; ?>,'<?php echo base_url("index.php/wap/index/togame/{$val['id']}").'?channel=hot'; ?>');"
                                               class="btn btn-play">开始游戏</a>
                                        </p>
                                    </div>
                                    <div class="info-left">
                                        <p class="hd"><?php echo $val['title']; ?></p>
                                        <p>
                                            <span class="tag tag-hot">hot</span>
                                        </p>
                                        <p class="desc"><?php echo $val['description']; ?></p>
                                    </div>
                                </div>
                            </li>
                        <?php } ?>
                        <?php
                        //加载adsense广告
                        $this->load->view('wap/adsense.php',$adsense['hot_list']);
                        ?>
                    </ul>
                </div>
            </div>
            <!-- 最近玩过 -->
            <div role="tabpanel" class="tab-pane" id="nav-recommend">
                <div class="bd-recommend">
                    <div class="tab-content">
                        <ul class="ul-recommend">
                            <?php foreach ($recommend as $key => $val) {?>
                                    <li>
                                        <a href="<?php echo site_url('wap/index/togame/' . $val['gameid']) .'?channel=history'; ?>">
                                            <p class="hd3"><?php echo $val['title']; ?></p>
                                            <div>
                                                <img class="thumb" src="<?php if ($val['picture']) {
                                                    echo base_url() . $val['picture'];
                                                } else {
                                                    echo base_url() . 'default/wap/img/g2.jpg';
                                                } ?>"/>
                                                <div class="ul-recommend-r">
                                                    <p class="tag-name pd-t3">最近游戏时间：</p>
                                                    <p class="tag-name">
                                                     <?php
                                                        if (time()-$val['visit_time'] > 3600*7*24)
                                                        {
                                                            echo date('Y-m-d H:i:s', $val['visit_time']);
                                                        }
                                                        else
                                                        {
                                                            echo timespan($val['visit_time'],time(),1).'前';
                                                        }
                                                     ?>
                                                    </p>
                                                </div>
                                            </div>
                                        </a>
                                    </li>
                            <?php } ?>
                        </ul>
                    </div>
                    <?php if(!empty($history_recommend)){?>
                    <div class="hr-custom"></div>
                    <!--当历史记录少于等于6个时，显示4个推荐-->
                    <div class="fd-page">
                        <div style="margin: 0 2% 10px;">大家都在玩</div>
                        <div class="owl-carousel owl-page">
                            <div>
                                <ul>
                                    <?php foreach($history_recommend as $key=>$val){ ?>
                                        <li>
                                            <a href="<?=base_url("index.php/wap/index/togame/{$val['id']}").'?channel=hrecommend';?>">
                                                <img class="thumb" src="<?php if($val['picture']){echo base_url().$val['picture'];}else{echo base_url().'default/wap/img/g2.jpg';} ?>">
                                                <p><?php echo $val['title']; ?></p>
                                            </a>
                                        </li>
                                    <?php } ?>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <?php } ?>
                    <hr>
                </div>
            </div>
            <div style="height: 20px; text-align: center; margin: 10px 0;">—— 页面有底，欢乐无限 ——</div>
        </div>
        <!--关注我们二维码弹框-->
        <div class="modal fade" id="gh_qrcode" data-backdrop="static" data-keybord="false" style="text-align: center;">
            <div class="modal-dialog modal-sm" style="width: 70%; margin: 20% auto">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">17koko游戏</h4>
                    </div>
                    <div class="modal-body">
                        <img src="<?php echo base_url(); ?>default/wap/img/i17kok.jpg" style="width: 100%">
                        <div >长按识别二维码</div>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        function click_ajax(id, url) {
            window.location.href = url;
        }
    </script>
<?php $this->load->view('wap/foot.php'); ?>